package com.bridgeintelligent.tag.webserver.schedule.service.task;

import com.bridgeintelligent.tag.webserver.schedule.api.IQualityService;
import com.bridgeintelligent.tag.webserver.schedule.api.ITaskLogService;
import com.bridgeintelligent.tag.webserver.schedule.api.enums.TaskEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @description 标签质量
 * @author: grp 2020-09-14 10:24
 **/
@Component
@Slf4j
@AllArgsConstructor
public class DimFreeQualityTask {

    private IQualityService qualityService;
    private ITaskLogService taskLogService;
    /**
     * 每天凌晨八点
     */
    @Scheduled(cron = "0 30 7 * * ?")
    public void updateJob() {
        log.info("更新自定义标签质量任务 开始");
        String date = DateFormatUtils.format(new Date(),"yyyy-MM-dd");
        qualityService.update(date);
        log.info("更新自定义标签质量任务 结束");
        taskLogService.save(TaskEnum.TASK_FREE_Q.getId());
    }
}
